home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
-
- set -e
-
- MYNAME="$0"
-
- # $* message
- warn() { echo "${MYNAME}: Warning: $*" >&2 ; }
-
- # $* message
- report_error() { echo "${MYNAME}: Error: $*" >&2 ; }
-
- udev_is_active()
- {
- test -e /dev/.udev.tdb || test -d /dev/.udevdb || return 1
- return 0
- }
-
- case "$1" in
- configure|reconfigure)
- # Decide which conf file to read
- conf_file=""
- if [ -f /etc/default/alsa ] ; then
- conf_file=/etc/default/alsa
- elif [ -f /usr/share/alsa-base/alsa.default ] ; then
- conf_file=/usr/share/alsa-base/alsa.default
- else
- report_error "No configuration file found"
- exit 1
- fi
- # Read variables from conf file
- force_unload_modules_before_suspend="$(
- . "$conf_file" >/dev/null 2>&1
- echo "$force_unload_modules_before_suspend"
- )"
- # Write new conf file
- cat /usr/share/alsa-base/alsa.default | sed \
- -e "s/force_unload_modules_before_suspend=.*/force_unload_modules_before_suspend=\"${force_unload_modules_before_suspend}\"/" \
- > /etc/default/alsa
- # Set up apm symlinks
- [ -f /etc/apm/scripts.d/alsa ] || warn "/etc/apm/scripts.d/alsa is absent"
- # $1: file to check
- already_linked_to_alsa()
- {
- [ "$1" ] || return 1
- [ -L "$1" ] || return 1
- [ "$(basename "$(readlink "$1")")" = alsa ] || return 1
- return 0
- }
- ALREADY_LINKED=no
- for F in /etc/apm/suspend.d/??alsa ; do
- already_linked_to_alsa "$F" && ALREADY_LINKED=yes && break
- done
- [ "$ALREADY_LINKED" = yes ] || ln -sf ../scripts.d/alsa /etc/apm/suspend.d/80alsa
- ALREADY_LINKED=no
- for F in /etc/apm/resume.d/??alsa ; do
- already_linked_to_alsa "$F" && ALREADY_LINKED=yes && break
- done
- [ "$ALREADY_LINKED" = yes ] || ln -sf ../scripts.d/alsa /etc/apm/resume.d/20alsa
- ;;
- abort-upgrade|abort-remove|abort-deconfigure)
- # We don't have to do anything because we didn't do anything in prerm
- exit 0
- ;;
- *)
- echo "postinst called with unknown argument \`$1'" >&2
- exit 1
- ;;
- esac
-
-
-